/*
			Author: Ozcan Degirmenci (Boot)
			E-Mail: odegirmenci@hotmail.com
			Date:	31 Jan 2005
*/

using System;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace Ling.ZhControls
{
	/// <summary>
	///  Delegate for SimpeTabControl DrawItem event
	/// </summary>
	public delegate void SimpleTabDrawItemEventHandler (object sender, 
							SimpleTabDrawItemEventArgs e);
	/// <summary>
	///  Event Args for Boot SimpleTab Control 
	/// </summary>
	public class SimpleTabDrawItemEventArgs : EventArgs
	{
		SimpleTabPage			_Item				= null				;
		Rectangle				_TabBounds			= Rectangle.Empty	;
		Brush					_BackBrush			= null				;
		Point[]					_TabPath			= null				;
		Color					_TextColor			= Color.Empty		;
		Graphics				_Graphics			= null				;

		internal SimpleTabDrawItemEventArgs (SimpleTabPage item,
			Brush backBrush, Point[] tabPath,
			Graphics graphics)
		{
			_Item = item;
			_TabBounds = item.TabRectangle;
			_BackBrush = backBrush;
			_TabPath = tabPath;
			_Graphics = graphics;
		}

		public void DrawbackGround ()
		{
			Graphics.FillPolygon(BackBrush, TabPath);
		}

		public void DrawBroders ()
		{
			if (Item.TabControl == null)
				throw new InvalidOperationException ("Operation must need a SimpleTabControl");
			Pen border = new Pen(Item.TabControl.BorderColor);
			if(Item.IsSelected)
			{
				Graphics.DrawPolygon(border, TabPath);
			}
			else
			{
				Graphics.DrawLine(border, TabPath[0], TabPath[1]);
				Graphics.DrawLine(border, TabPath[1], TabPath[2]);
				Graphics.DrawLine(border, TabPath[2], TabPath[3]);
				Graphics.DrawLine(border, TabPath[3], TabPath[4]);
				
				Graphics.DrawLine(new Pen(Item.TabControl.SelectedTabColor), 
					TabPath[4], TabPath[0]);
			}
			border.Dispose();
		}

		public SimpleTabPage Item
		{
			get {return _Item;}
		}

		public Rectangle TabBounds
		{
			get {return _TabBounds;}
		}

		public Brush BackBrush
		{
			get {return _BackBrush;}
		}

		public Point[] TabPath
		{
			get {return _TabPath;}
		}

		public Graphics Graphics
		{
			get {return _Graphics;}
		}
	}
}
